package com.dunqi.gpm.shunqing.my.util;

import com.dunqi.gpm.shunqing.common.base.Data3;
import com.dunqi.gpm.shunqing.common.util.CommonUtil;
import com.dunqi.gpm.shunqing.common.util.SharedPreferencesUtils;
import com.dunqi.gpm.shunqing.my.LoginActivity;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;
import cn.jpush.android.data.JPushLocalNotification;

/**
 * Created by Administrator on 2017/12/17.
 */

public class JpushUtil {

    public static Set<String> setTags(List<Data3> data3) {
        Set<String> tags1 = new HashSet<>();
        for (Data3 data31 : data3) {
            String roleCode = data31.getRoleCode();
            tags1.add(roleCode);
        }
        SharedPreferencesUtils.putSetData(LoginActivity.USER_TAGS, tags1);
        Set<String> tags = JPushInterface.filterValidTags(tags1);
        tags1.removeAll(tags);
        JPushInterface.setTags(CommonUtil.getContext(), 2, tags);
        return tags1;
    }

    public static Set<String> setTags(Set<String> tags1) {
        Set<String> tags = JPushInterface.filterValidTags(tags1);
        JPushInterface.setTags(CommonUtil.getContext(), 2, tags);
        tags1.removeAll(tags);
        return tags1;
    }

    public static void setAlias(final TagAliasCallback aliasCallback) {
        String deviceId = CommonUtil.getDeviceId();
        JPushInterface.setAlias(CommonUtil.getContext(), deviceId, aliasCallback);
        JPushInterface.addLocalNotification(CommonUtil.getContext(), new JPushLocalNotification());
    }


}
